package com.gj.spartprice.mapper;

import com.gj.spartprice.model.FactoryVo;
import com.gj.spartprice.model.SpartPriceServiceVo;
import com.gj.spartprice.model.SpartPriceVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Created by Tangyunhen on 2021-07-05.
 */
@Mapper
public interface SpartPriceMapper {



    List<SpartPriceVo> queryDate(SpartPriceServiceVo spartPriceServiceVo);

    int queryCount(SpartPriceServiceVo spartPriceServiceVo);

    @Select("select * from legalperson where legalPersonCode=#{legalPersonCode}")
    SpartPriceVo queryBylegalPersonCode(String legalPersonCode);

    @Select("SELECT * FROM factory f\n" +
            "LEFT JOIN legelperson l ON f.id=l.pid\n" +
            "where f.legalPersonCode =#{legalPersonCode}\n" +
            "AND f.legalPlantCode LIKE CONCAT(#{legalPlantCode},'%')")
    List<FactoryVo> queryByCodeLike(@Param("legalpersonCode") String legalpersonCode, @Param("legalPlantCode")String legalPlantCode);

    @Insert("insert into spartprice (legalPersonCode,legalPersonName,legalPlantName,priceType,code,name,materialCode,taxType,Partprice,startTime,endTime,Remark) values " + "(#{legalPersonCode},#{legalPersonName},#{legalPlantName},#{priceType},#{code},#{name},#{materialCode},#{taxType},#{Partprice},#{startTime},#{endTime},#{Remark})")
    void insert(SpartPriceVo spartPriceVo);

    @Select("select * from priceVo where priceCode=#{priceCode},priceType=#{priceCode}")
    List<SpartPriceVo> querypriceClass();
}

